<?php echo $header;echo $sidebar ?>		

		<div class="span10 content">


			<?php echo $hugemenu ?>

			<h1><?php //echo lang('sidebar_estate_showcase');?></h1>

			<?php if($this->session->flashdata('message')) {?>

			<div class="alert alert-success">

				<?php echo $this->session->flashdata('message') ?>

			</div>

			<?php  }?>

			<div>

				<link rel="stylesheet" href="<?php echo base_url(); ?>assets/admin/css/new_font-awesome.css"/>
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/jquery-ui.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen-bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/chosen.jquery.js"></script>
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/media/js/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
	<style type="text/css">
	
	
	.select_filter {width: 100% !important;padding:0 !important;height: auto !important;margin:0 !important;}
	.btn-group, .btn-group-vertical {display: inline-block;position: relative;vertical-align: middle;}
	* {border-radius: 0 0 0 0 !important;box-shadow: none !important;font-family: "Open Sans",Arial,Helvetica,sans-serif;font-weight: 400;text-shadow: none !important;}
	.btn-group > .btn:first-child {margin-left: 0;}
	.btn-group a.btn {margin: 0 !important;}
	.btn.btn-primary {background: none repeat scroll 0 0 #1171A3 !important;}
	.btn-xs {padding: 1px 5px;}
	.btn-sm, .btn-xs {border-radius: 3px 3px 3px 3px;font-size: 12px;line-height: 1.5;padding: 2px 5px;}
	.tooltip, .fa {font-size: 15px;}
	.fa {display: inline-block;font-family: FontAwesome;font-style: normal;font-weight: normal;line-height: 1;}
	.btn-group, .btn-group-vertical {display: inline-block;position: relative;vertical-align: middle;}
	
	.modal-header .close {margin-top: -2px;}
	.modal-content {box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);}
	.modal-content {
		background-clip: padding-box;
	    background-color: #FFFFFF;
	    border: 1px solid rgba(0, 0, 0, 0.2);
	    border-radius: 6px 6px 6px 6px;
	    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
	    outline: 0 none;
	    position: relative;
	}	
	button.close {background: none repeat scroll 0 0 transparent;border: 0 none;cursor: pointer;padding: 0;}
	
	.table tfoot th:nth-child(5), .table td:nth-child(5), .table tfoot th:nth-child(6), .table td:nth-child(6), .table tfoot th:nth-child(7), .table td:nth-child(7) {text-align: right;}
	.table td:nth-child(6) {text-transform: capitalize;}
	.table td {width:10%;}
	.table td:first-child, .table td:nth-child(8) {width: 6%;}
	.table td:nth-child(8) {text-align:center;}
	.table td:nth-child(8) span { display:block; }
	.table td:nth-child(3), .table td:nth-child(5), .table td:nth-child(6), .table td:nth-child(7) {width:5%;}
	.text_filter {
		width: 100% !important;
		border: 0 !important;
		box-shadow: none !important;
		border-radius: 0 !important;
		padding:0 !important;
		margin:0 !important;
		font-size: 1em !important;
	}
	
	/* Label colors */
	.label.label-success, .badge.badge-success{background: #43c83c !important;}
	.label.label-warning, .badge.badge-warning{background: #f88529 !important;}
	.label.label-important, .badge.badge-important{background: #fa3031 !important;}
	.label.label-info, .badge.badge-info{background: #52b9e9 !important;}
	
	.col-md-6{float:left;width:47%;}
	#dataTables_filter{float:right;}
	
	.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
    	min-height: 1px;
    	padding-left: 15px;
    	padding-right: 15px;
    	position: relative;
	}

	</style>
	
<script>
             $(document).ready(function() {

            	 function format_date(oObj) {
 					var aDate = oObj.split('-');
 					<?php if(JS_DATE == 'dd-mm-yy') { ?>
 					return aDate[2] + "-" + aDate[1] + "-" + aDate[0];
 					<?php } elseif(JS_DATE == 'dd/mm/yy') { ?>
 					return aDate[2] + "/" + aDate[1] + "/" + aDate[0];
 					<?php } elseif(JS_DATE == 'dd.mm.yy') { ?>
 					return aDate[2] + "." + aDate[1] + "." + aDate[0];
 					<?php } elseif(JS_DATE == 'mm/dd/yy') { ?>
 					return aDate[1] + "/" + aDate[2] + "/" + aDate[0];
 					<?php } elseif(JS_DATE == 'mm-dd-yy') { ?>
 					return aDate[1] + "-" + aDate[2] + "-" + aDate[0];
 					<?php } elseif(JS_DATE == 'mm.dd.yy') { ?>
 					return aDate[1] + "." + aDate[2] + "." + aDate[0];
 					<?php } else { ?>
 					return sValue;
 					<?php } ?>
 				}
  				
                $('#fileData').dataTable( {
                	
					"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                    "aaSorting": [[ 1, "desc" ]],
                    "iDisplayLength":10 <?php //echo ROWS_PER_PAGE; ?>,
                    <?php //if(BSTATESAVE) { echo '"bStateSave": true,'; } ?>
					'bProcessing'    : true,
					'bServerSide'    : true,
					'sAjaxSource'    : '<?php echo base_url(); ?>index.php/inventories/getdatatableajax<?php 
					if($search_term) { echo "&search_term=".$search_term; } ?>',
					'fnServerData': function(sSource, aoData, fnCallback)
					{
						aoData.push( { "name": "<?php echo $this->security->get_csrf_token_name(); ?>", "value": "<?php echo $this->security->get_csrf_hash() ?>" } );
					  $.ajax
					  ({
						'dataType': 'json',
						'type'    : 'POST',
						'url'     : sSource,
						'data'    : aoData,
						'success' : fnCallback
					  });
					},	
					"oTableTools": {
						"sSwfPath" : "<?php echo $this->config->base_url(); ?>/assets/admin/media/swf/copy_csv_xls_pdf.swf",
						"aButtons": [
				    	 				"csv",
				    	 				"xls",
				    	 				{
				    	 					"sExtends": "pdf",
				    	 					"sPdfOrientation": "landscape",
				    	 					"sPdfMessage": "Your custom message would go here."
				    	 				},
				    	 				"print"
			    	 				]
					},
					"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
						var row_total = 0; tax =0; gtotal = 0;
						for ( var i=0 ; i<aaData.length ; i++ )
						{
							row_total += parseFloat(aaData[ aiDisplay[i] ][3]);
							tax += parseFloat(aaData[ aiDisplay[i] ][4]);
							gtotal += parseFloat(aaData[ aiDisplay[i] ][5]);
						}
						
						var nCells = nRow.getElementsByTagName('th');
						nCells[3].innerHTML = parseFloat(row_total).toFixed(2);
						nCells[4].innerHTML = parseFloat(tax).toFixed(2);
						nCells[5].innerHTML = parseFloat(gtotal).toFixed(2);
					}
                }).columnFilter({ aoColumns: [
						{ type: "text", bRegex:true },
						{ type: "text", bRegex:true },
						{ type: "text", bRegex:true },
						null, null, null, null
                     ]});
				
            });
                    
</script>
<?php if($message) { echo "<div class=\"alert alert-error\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $message . "</div>"; } ?>
<?php if($success_message) { echo "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $success_message . "</div>"; } ?>

<div class="btn-group pull-right" style="margin-left: 25px;">
<a href="#" class="btn btn-success span dropdown-toggle" data-toggle="dropdown"><?php echo $this->lang->line("all_warehouses"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
    <?php
	foreach($warehouses as $warehouse) {
		echo "<li><a href='index.php?module=inventories&view=warehouse&warehouse_id=".$warehouse->id."'>".$warehouse->name."</a></li>";	
	}
	?>
    </ul>
    </div>
    <h3 class="title"><?php echo $page_title; ?></h3>

	<table id="fileData" class="table table-bordered table-hover table-striped table-condensed" style="margin-bottom: 5px;">
 
		<thead>
        <tr>
            <th><?php echo $this->lang->line("date"); ?></th>
			<th><?php echo $this->lang->line("ref_no"); ?></th>
            <th><?php echo $this->lang->line("supplier"); ?></th>
            <th><?php echo $this->lang->line("total"); ?></th>
            <th><?php echo $this->lang->line("product_tax"); ?></th>
            <th><?php echo $this->lang->line("grand_total"); ?></th>
            <th><?php echo $this->lang->line("actions"); ?></th>
		</tr>
        </thead>
		<tbody>
			<tr>
            	<td colspan="7" class="dataTables_empty">Loading data from server</td>
			</tr>
        </tbody>
        <tfoot>
        <tr>
            <th>[<?php echo $this->lang->line("date"); ?> (yyyy-mm-dd)]</th>
			<th>[<?php echo $this->lang->line("ref_no"); ?>]</th>
            <th>[<?php echo $this->lang->line("supplier"); ?>]</th>
            <th>[<?php echo $this->lang->line("total"); ?>]</th>
            <th><?php echo $this->lang->line("product_tax"); ?></th>
            <th><?php echo $this->lang->line("grand_total"); ?></th>
            <th><?php echo $this->lang->line("actions"); ?></th>
		</tr>
        </tfoot>
	</table>
	<p>
		<a href="<?php echo site_url('inventories/add');?>" class="btn btn-primary"><?php echo $this->lang->line("add_purchase"); ?></a>
	</p>
	
	
	

			

			<?php echo $pagination ?>



		</div><!--/content-->


		<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui-1.10.2.custom.min.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/sparklines.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/bootstrap-datetimepicker.min.js"></script> <!-- Date picker -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/DT_bootstrap.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto -->


<?php echo $footer ?>